import CheckboxItem from "../formItems/CheckboxItem.vue";
import DateItem from "../formItems/DateItem.vue";
import InputItem from "../formItems/InputItem.vue";
import InputNumberItem from "../formItems/InputNumberItem.vue";
import RadioItem from "../formItems/RadioItem.vue";
import SelectItem from "../formItems/SelectItem.vue";
import SwitchItem from "../formItems/SwitchItem.vue";
import UploadItem from "../formItems/UploadItem.vue";
import ImageUploadItem from "../formItems/ImageUploadItem.vue";

export type Type =
  | "input"
  | "input-number"
  | "select"
  | "radio"
  | "checkbox"
  | "multiple-select"
  | "date"
  | "date-time"
  | "switch"
  | "upload"
  | "image-upload";

export interface FormField {
  label: string;
  prop: string;
  type: Type;
  options?: { label: string; value: string }[];
  rules?: { rule: string; message: string }[];
  min?: number;
  max?: number;
  step?: number;
  action?: string;
  fileType?: string[];
  fileSize?: number;
  limit?: number;
  required: boolean;
}

export interface Rule {
  required?: boolean;
  message?: string;
  trigger?: string | string[];
  pattern?: RegExp;
  type?: string;
  min?: number;
  max?: number;
  // 添加其他可能的规则属性
}
// 值为数组的组件
export const arrType = [
  "checkbox",
  "multiple-select",
  "upload",
  "image-upload"
];

// 值为布尔值的组件
export const boolType = ["switch"];

// 组件map
export const componentMap = {
  input: InputItem,
  "input-number": InputNumberItem,
  select: SelectItem,
  radio: RadioItem,
  checkbox: CheckboxItem,
  "multiple-select": SelectItem,
  date: DateItem,
  "date-time": DateItem,
  switch: SwitchItem,
  upload: UploadItem,
  "image-upload": ImageUploadItem
};

// 需要选项的组件
export const requireOption = ["select", "radio", "checkbox", "multiple-select"];

// 文件类型下拉
export const fileTypeOptions = [
  { label: "图片文件", value: ".jpg,.jpeg,.png,.gif" },
  { label: "PDF文件", value: ".pdf" },
  { label: "Word文档", value: ".doc,.docx" },
  { label: "Excel表格", value: ".xls,.xlsx" },
  { label: "文本文件", value: ".txt" },
  { label: "所有文件", value: "*" }
];
